<?php
namespace BWL\webshopBundle\DataFixtures\ORM;
/**
 * Created by JetBrains PhpStorm.
 * User: leon
 * Date: 11/19/12
 * Time: 10:04 PM
 * To change this template use File | Settings | File Templates.
 */


use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\Persistence\ObjectManager;
use BWL\webshopBundle\Entity\ItemItem;

class ItemItemFixtures extends AbstractFixture implements OrderedFixtureInterface
{
  public function load(ObjectManager $manager) {
    $ab = new ItemItem();
    $ab->setWholeItem($manager->merge($this->getReference('itemA')));
    $ab->setPartItem($manager->merge($this->getReference('itemB')));
    $ab->setCount(1);
    $manager->persist($ab);

    $bc = new ItemItem();
    $bc->setWholeItem($manager->merge($this->getReference('itemB')));
    $bc->setPartItem($manager->merge($this->getReference('itemC')));
    $bc->setCount(1);
    $manager->persist($bc);

    $ad = new ItemItem();
    $ad->setWholeItem($manager->merge($this->getReference('itemA')));
    $ad->setPartItem($manager->merge($this->getReference('itemD')));
    $ad->setCount(2);
    $manager->persist($ad);

    $ae = new ItemItem();
    $ae->setWholeItem($manager->merge($this->getReference('itemA')));
    $ae->setPartItem($manager->merge($this->getReference('itemE')));
    $ae->setCount(1);
    $manager->persist($ae);

    $af = new ItemItem();
    $af->setWholeItem($manager->merge($this->getReference('itemA')));
    $af->setPartItem($manager->merge($this->getReference('itemF')));
    $af->setCount(1);
    $manager->persist($af);

    $ag = new ItemItem();
    $ag->setWholeItem($manager->merge($this->getReference('itemA')));
    $ag->setPartItem($manager->merge($this->getReference('itemG')));
    $ag->setCount(1);
    $manager->persist($ag);

    $ah = new ItemItem();
    $ah->setWholeItem($manager->merge($this->getReference('itemA')));
    $ah->setPartItem($manager->merge($this->getReference('itemH')));
    $ah->setCount(1);
    $manager->persist($ah);

    $ai = new ItemItem();
    $ai->setWholeItem($manager->merge($this->getReference('itemA')));
    $ai->setPartItem($manager->merge($this->getReference('itemI')));
    $ai->setCount(1);
    $manager->persist($ai);

    $ij = new ItemItem();
    $ij->setWholeItem($manager->merge($this->getReference('itemI')));
    $ij->setPartItem($manager->merge($this->getReference('itemJ')));
    $ij->setCount(1);
    $manager->persist($ij);

    $la = new ItemItem();
    $la->setWholeItem($manager->merge($this->getReference('itemL')));
    $la->setPartItem($manager->merge($this->getReference('itemA')));
    $la->setCount(1);
    $manager->persist($la);

    $lk = new ItemItem();
    $lk->setWholeItem($manager->merge($this->getReference('itemL')));
    $lk->setPartItem($manager->merge($this->getReference('itemK')));
    $lk->setCount(1);
    $manager->persist($lk);

    $mn = new ItemItem();
    $mn->setWholeItem($manager->merge($this->getReference('itemM')));
    $mn->setPartItem($manager->merge($this->getReference('itemN')));
    $mn->setCount(1);
    $manager->persist($mn);

    $im = new ItemItem();
    $im->setWholeItem($manager->merge($this->getReference('itemI')));
    $im->setPartItem($manager->merge($this->getReference('itemM')));
    $im->setCount(1);
    $manager->persist($im);


    $manager->flush();
  }

  /**
   * Insertion order
   * @return int
   */
  public function getOrder() {
    return 4;
  }
}
